package com.yuandian.management.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuandian.api.management.entity.ConfUnconfirmedUrl;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.management.service.ConfUnconfirmedUrlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;


/**
 * 未确认URL资源表-Controller
 * @author zfsn
 * @date 2023-3-16
 */
@Api(tags = "业务系统配置-IT云化资源配置-未确认")
@RestController
@RequestMapping("/unconfirmedUrl")
public class ConfUnconfirmedUrlController {

	@Autowired
	private ConfUnconfirmedUrlService confUnconfirmedUrlService;


	/**
	 * 分页查询
	 *
	 * @param confUnconfirmedUrl 筛选条件
	 * @return 通用返回对象
	 */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "prefixUrl", value = "url", paramType = "body", required = true, dataType = "String"),
			@ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "body", required = true, dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "pageNum", value = "当前页数", paramType = "body", required = true, dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "orderByColumn", value = "排序列", paramType = "body", required = true, dataType = "String"),
			@ApiImplicitParam(name = "isAsc", value = "排序的方向值只能是 desc 或者 asc", paramType = "body", required = true, dataType = "String")
	})
	@ApiOperation(value = "分页查询", notes = "分页查询")
	@PostMapping
	public R<Page<ConfUnconfirmedUrl>> listPage(@RequestBody @ApiIgnore ConfUnconfirmedUrl confUnconfirmedUrl) {
		return R.ok(confUnconfirmedUrlService.listPage(confUnconfirmedUrl));
	}

	/**
	 * 分页查询url映射列表
	 *
	 * @param confUnconfirmedUrl 筛选条件
	 * @return 通用返回对象
	 */
	@ApiImplicitParams({
			@ApiImplicitParam(name = "prefixUrl", value = "url", paramType = "body", required = true, dataType = "String"),
			@ApiImplicitParam(name = "pageSize", value = "每页大小", paramType = "body", required = true, dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "pageNum", value = "当前页数", paramType = "body", required = true, dataTypeClass = Integer.class),
	})
	@ApiOperation(value = "分页查询url映射列表", notes = "分页查询url映射列表")
	@PostMapping("/getUrlMappingPage")
	public R<Page<ConfUnconfirmedUrl>> getUrlMappingPage(@RequestBody @ApiIgnore ConfUnconfirmedUrl confUnconfirmedUrl) {
		return R.ok(confUnconfirmedUrlService.getUrlMappingPage(confUnconfirmedUrl));
	}

	/**
	 * 确认资源
	 * @param confUnconfirmedUrl 筛选条件
	 * @return 通用返回对象
	 */
	@ApiOperation(value = "确认资源", notes = "确认资源")
	@PostMapping("/confirmResource")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "prefixUrl", value = "url", paramType = "body", required = true, dataType = "String"),
			@ApiImplicitParam(name = "segmentIds", value = "所属网端id(多选)", paramType = "body", required = true, dataTypeClass = Integer.class),
			@ApiImplicitParam(name = "systemId", value = "所属系统id", paramType = "body", required = true, dataTypeClass = Integer.class),
	})
	public R<String> confirmResource(@RequestBody @ApiIgnore ConfUnconfirmedUrl confUnconfirmedUrl) {
		return confUnconfirmedUrlService.confirmResource(confUnconfirmedUrl);
	}




	/**
	 * 添加黑名单
	 * @param confUnconfirmedUrl 筛选条件
	 * @return 通用返回对象
	 */
	@ApiOperation(value = "添加黑名单", notes = "添加黑名单")
	@PostMapping("/addBlackListBatch")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "prefixUrls", value = "url(支持多选) 数组类型", paramType = "body", required = true, dataType = "String"),
	})
	public R<String> addBlackListBatch(@RequestBody @ApiIgnore ConfUnconfirmedUrl confUnconfirmedUrl) {
		return confUnconfirmedUrlService.addBlackListBatch(confUnconfirmedUrl);
	}



}
